<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form action="http://www.baidu.com">
    <input type="text" name="user">
    <input type="submit" value="提交">
</form>
<a href="http://www.baidu.com">百度一下</a>
<script>
var form = document.querySelector("form");
form.addEventListener("submit", function (event){
    console.log("submit...", alert(event.type));
    event.preventDefault();  // 阻止默认行为
});
var a = document.querySelector("a");
a.addEventListener("click", function (event){
    console.log("cancelable", event.cancelable);  // 是否可以取消
    console.log("defaultPrevented", event.defaultPrevented);
    event.preventDefault();
    console.log("defaultPrevented", event.defaultPrevented);

})
</script>
</body>
</html>